package com.aaa.system.controller;

import com.aaa.annotation.Auth;
import com.aaa.entity.Permission;
import com.aaa.system.service.PermissionService;
import com.aaa.utils.JWTUtil;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @program: aaa-education-parent
 * @description:
 * @author: 闫克起2
 * @create: 2024-03-06 11:37
 **/
@RestController
@RequestMapping("/system/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;
    @GetMapping("getByUserId/{userId}")
    public List<Permission> getByUserId(@PathVariable String userId){
         return permissionService.queryByUserId(userId);
    }

    @GetMapping("leftMenu")
    public Result leftMenu(HttpServletRequest request){
        String token = request.getHeader("token");
        String name = JWTUtil.getName(token);
        List<Permission> permissions = permissionService.queryByUsername(name);
        return new Result(2000,"查询左侧菜单成功",permissions);
    }
@GetMapping("role")
    @Auth(value = "role:list")
    public Result role(){
        return new Result(2000,"333333",null);
    }




}
